package ModelLayer;
import java.util.*;//Used for ArrayList

public class AddressBook
{
    public ArrayList<Person> person;
    //Instance variable

    public AddressBook()
    { 
        person = new ArrayList<Person>();
        // initialise instance variable
    }

    /**
     * Method to find a person based by an id
     */
    public Person findPerson(long _id)
    {
        Person tempPers = null;
        int i= 0;
        boolean found= false;
        while ( !found && i<person.size())
        {
            Person per = person.get(i);
            if (per.getID() == _id)
            {
                tempPers = per;
                found= true;
            }
            else
                i++;
        }

        return tempPers;
    }
    /**
     * Methods to add/remove a person
     */
    public void addPerson(Person _empName)
    {   
        person.add(_empName);
    }

    public void removePerson(Person _p)
    {
        person.remove(_p);
    }

}
